<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TRole" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TRole" type="EIA.PM.Model.TRole, EIA.PM.Model" />
</alias>

<resultMaps>
<resultMap id="select-trole-result" class="TRole">
<constructor>
    <argument argumentName="role_id" column="role_id"/>
    <argument argumentName="role_name" column="role_name"/>
    <argument argumentName="role_fun_auth" column="role_fun_auth"/>
</constructor>
<!--
    <result property="RoleId" column="role_id"/>
    <result property="RoleName" column="role_name"/>
    <result property="RoleFunAuth" column="role_fun_auth"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TRole_where_pk">
WHERE role_id=#RoleId#
</sql>

<sql id="sql_TRole_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="RoleId" prepend="AND">role_id=#RoleId#</isPropertyAvailable>
    <isPropertyAvailable property="RoleName" prepend="AND">role_name LIKE concat('%', #RoleName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="RoleFunAuth" prepend="AND">role_fun_auth LIKE concat('%', #RoleFunAuth#, '%')</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TRole_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="RoleName" prepend=",">role_name=#RoleName#</isPropertyAvailable>
    <isPropertyAvailable property="RoleFunAuth" prepend=",">role_fun_auth=#RoleFunAuth#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTRole" parameterClass="" resultMap="TRole.select-trole-result">
SELECT *
FROM t_role
<include refid="sql_TRole_where_pk"/><!--where-->
</select>

<select id="SelectTRole_CV" parameterClass="System.Collections.IDictionary" resultMap="TRole.select-trole-result">
SELECT *
FROM t_role
<include refid="sql_TRole_where_cv"/><!--where-->
</select>

<insert id="InsertTRole" parameterClass="TRole">
<!--pre selectKey place-->
INSERT INTO t_role(
<dynamic prepend=" ">
    <isPropertyAvailable property="RoleName" prepend=",">role_name</isPropertyAvailable>
    <isPropertyAvailable property="RoleFunAuth" prepend=",">role_fun_auth</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="RoleName" prepend=",">#RoleName#</isPropertyAvailable>
    <isPropertyAvailable property="RoleFunAuth" prepend=",">#RoleFunAuth#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="RoleId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTRole" parameterClass="System.Collections.IDictionary">
UPDATE t_role
<include refid="sql_TRole_set_cols"/><!--set-->
<include refid="sql_TRole_where_pk"/><!--where-->
</update>

<delete id="DeleteTRole" parameterClass="">
DELETE FROM t_role
<include refid="sql_TRole_where_pk"/><!--where-->
</delete>

<statement id="DeleteTRole_CV" parameterClass="TRole">
DELETE FROM t_role
<include refid="sql_TRole_where_cv"/><!--where-->
</statement>

<delete id="ClearTRole">
DELETE FROM t_role
</delete>
</statements>
</sqlMap>